﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace QuanLyKhachSan
{
    public partial class UC_DichVu_Edit : System.Web.UI.UserControl
    {
        private int DichVuID = -1;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (this.Request.QueryString["DichVuID"] != null)
                {
                    DichVuID = int.Parse(this.Request.QueryString["DichVuID"].ToString());
                }
                if (!Page.IsPostBack)
                {
                    if (DichVuID != -1)
                    {
                        DichVu_Load();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// DichVu_Load
        /// </summary>
        protected void DichVu_Load()
        {
            try
            {
                DichVuInfo item = DichVuBLL.DichVu_GetItem(DichVuID);
                txtDichVuName.Text = item.DichVuName;
                txtGiaTien.Text = item.GiaTien.ToString();  
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void cmdOK_Click(object sender, EventArgs e)
        {
            try
            {
                string DichVuName = txtDichVuName.Text;
                decimal GiaTien = (decimal)txtGiaTien.Value;
                if (DichVuID == -1)
                {
                    DichVuBLL.DichVu_Add(DichVuName,GiaTien);   
                }
                else
                {
                    DichVuBLL.DichVu_Edit(DichVuID, DichVuName, GiaTien);
                }
                hfStatus.Value = "1";
            }
            catch (Exception)
            {
                
                throw;
            }
        }
}
}
